/*
 * IAnimationController.h
 *
 *  Created on: 05.01.2012
 *      Author: Kirill Blinov
 *      Copyright: LGPL
 */

#ifndef IANIMATIONCONTROLLER_H_
#define IANIMATIONCONTROLLER_H_

#include <vector>
#include "IAnimationState.h"
#include "IAnimationPlayer.h"
#include "IAnimationInterface.h"
#include "./Physics Engine/IPhysicsObject.h"

class GAME_SUBOBJECT_INSTANCE;

class CAnimationController
{
friend class AnimationFabric;
private:
	CAnimationController( std::vector<CBasicAnimation*> &AnimationArray,
						  IPhysicsObject* PhysicsObject,
						  GAME_SUBOBJECT_INSTANCE* GameObject );

	/*
	 * Replace an animation with the same name as NewAnimation have from AnimationArray
	 * return: true - if an animation with required name exists, otherwise false.
	 */
	bool ReplaceAnimation( CBasicAnimation &NewAnimation );

	/*
	 * Contains animation states, sorted in order of their names
	 */
	std::vector<CBasicAnimation*> animationArray;

	IPhysicsObject               *physicsObject;

	GAME_SUBOBJECT_INSTANCE      *gameObject;

protected:

	CBasicAnimation* FindAnimationByName( std::string Name );

public:

	virtual ~CAnimationController();

    IAnimationInterface* GetAnimationInterfaceByName( std::string AnimationName );

    IAnimationState* GetAnimationStateByName( std::string AnimationName );

    void SetGameObject( GAME_SUBOBJECT_INSTANCE* GameObject ){ gameObject = GameObject; };

    void PlayAnimations( IAnimationPlayer* AnimationPlayer );

    glm::mat4 GetObjectWorldPosition();
};

#endif /* IANIMATIONCONTROLLER_H_ */

